package com.example.mapper;

import com.example.entity.Course;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CourseMapper
{
    /**
     * 新增
     * @param course
     */
    void insert(Course course);

    /**
     * 根据Id查询课程
     * @param id
     * @return
     */
    Course selectById(Integer id);

    /**
     * 根据id删除课程
     * @param id
     */
    void deleteById(Integer id);


    /**
     * 修改课程
     * @param course
     */
    void updateById(Course course);

    /**
     * 查询所有课程
     * @param course
     * @return
     */
    List<Course> selectAll(Course course);
    
    @Select("select * from course where recommend = '是' and type = #{type};")
    Course getRecommend(String type);

    @Select("select * from course where recommend = '否' and type = #{type} order by id desc limit 8;")
    List<Course> selectTop8(String type);
}
